package com.hongfeng.web.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hongfeng.web.model.AutoBrand;
import com.hongfeng.web.model.BizInfo;
import com.hongfeng.web.model.BuyInfo;
import com.hongfeng.web.model.Contact;
import com.hongfeng.web.service.AutoBrandService;
import com.hongfeng.web.service.BizInfoService;
import com.hongfeng.web.service.BuyInfoService;
import com.hongfeng.web.service.ContactService;

@Controller
public class IndexController {

	@Resource
	private AutoBrandService autoBrandService;
	@Resource
	private BuyInfoService buyInfoService;
	@Resource
	private BizInfoService bizInfoService;
	@Resource
	private ContactService contactService;

	@RequestMapping("index")
	public String index(HttpServletRequest request,
			HttpServletResponse response, Model model) {
		// 品牌信息
		List<AutoBrand> autoBrands = autoBrandService.findAll();
		model.addAttribute("autoBrands", autoBrands);
		// 求购信息
		List<BuyInfo> buyInfos = buyInfoService.findAll();
		model.addAttribute("buyInfos", buyInfos);
		// 业务介绍
		BizInfo bizInfo = bizInfoService.find();
		model.addAttribute("bizInfo", bizInfo);
		// 联系方式
		Contact contact = contactService.find();
		model.addAttribute("contact", contact);
		return "index";
	}
}
